package data;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import pojo.Book;

public class DataCreator {
	private final static String FILENAME="D:\\data\\book.m";
	
	public void create(int num){
		try {
			ObjectOutputStream obOutputStream = new ObjectOutputStream(new FileOutputStream(FILENAME));
			List<Book> books = new ArrayList<Book>();
			for (int i = 0; i <num ; i++) {
				Book book = new Book(i,"book"+i,new Date(),"author"+i,25.23+i%10,i%2==1,"publisher"+i);
//				obOutputStream.writeObject(book);
				books.add(book);
				System.out.println(book.toString());
			}
			obOutputStream.writeObject(books);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	public static void main(String[] args) {
		new DataCreator().create(10000);
	}
}
